package j45;

import cn.hutool.core.thread.ThreadUtil;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author chengshuai
 * @date 2021/4/15 19:57
 */
public class MyThread implements Callable<Integer> {

    @Override
    public Integer call() throws Exception {
        ThreadUtil.sleep(5000);
        return 1024;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        //两个线程，一个main主线程，一个是AAfutureTask
        FutureTask<Integer> futureTask = new FutureTask<>(new MyThread());
        new Thread(futureTask, "AA").start();

        while (!futureTask.isDone()) {

        }

        Integer result01 = futureTask.get();

        System.out.println(Thread.currentThread().getName() + "*******");
        int result02 = 100;

        System.out.println("*****result:" + (result01 + result02));
    }

}
